home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / redo / redoPageMark.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  5.1 KB  |  215 lines

  1. /*
  2.  *   $RCSfile: redoPageMark.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:55 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38.  
  39. #include "sysdefs.h"
  40. #include "ess.h"
  41. #include "checking.h"
  42. #include "trace.h"
  43. #include "error.h"
  44. #include "list.h"
  45. #include "pool.h"
  46. #include "tid.h"
  47. #include "io.h"
  48. #include "page.h"
  49. #include "lock.h"
  50. #include "object.h"
  51. #include "msgdefs.h"
  52. #include "thread.h"
  53. #include "latch.h"
  54. #include "semaphore.h"
  55. #include "link.h"
  56. #include "lsn.h"
  57. #include "bf.h"
  58. #include "log.h"
  59. #include "volume.h"
  60. #include "logrecs.h"
  61. #include "trans.h"
  62. #include "bitmap.h"
  63. #include "openlog.h"
  64. #include "io_extfuncs.h"
  65. #include "bf_extfuncs.h"
  66. #include "bm_extfuncs.h"
  67. #include "trans_extfuncs.h"
  68. #include "redo_extfuncs.h"
  69. #include "redo_intfuncs.h"
  70. #include "logaction.h"
  71. #include "util_funcs.h"
  72. #include "thread_globals.h"
  73. #include "log_globals.h"
  74. #include "log_extfuncs.h"
  75.  
  76.  
  77.  void
  78. redoPageMark (
  79.  
  80.     LOGRECORDHDR        *record 
  81. )
  82. {
  83.  
  84.     VOLREC                *volRec;
  85.     PID                    *pid;
  86.     GROUPLINK            *groupLink;
  87.     PID                    *bitmapPid;
  88.     DIRTYPAGEINFO        *dirtyInfo;
  89.     BITMAPPAGE            *bitmapPage;
  90.  
  91.  
  92.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
  93.  
  94.     /*
  95.      *    get a pointer to the name in the record
  96.      */
  97.     pid = (PID *) GET_LOG_IMAGE(record, 0);
  98.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
  99.  
  100.     /*
  101.      *    Debugging is off, so assign the bitmap page to be the actionPid
  102.      */
  103.     bitmapPid = &(record->actionPid);
  104.  
  105.  
  106.     /*
  107.      *    check to see if the page is in the dirty page list
  108.      */
  109.     if ((dirtyInfo = searchDirtyPageTable( bitmapPid )) == NULL)    {
  110.  
  111.         /*
  112.          *    don't need to redo
  113.          */
  114.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
  115.         return;
  116.     }
  117.  
  118.     /*
  119.      *  check to see if the lrc on the page is greater than
  120.      *  the lrc in the log record.
  121.      *  Also check the lsn for the case of pages which never made it
  122.      *  back from the client.
  123.      */
  124.     if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
  125.  
  126.         /*
  127.          *  don't need to redo
  128.          */
  129.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
  130.         return;
  131.     }
  132.  
  133.     if ((volRec = io_FindVolRec(pid->volid)) == NULL)    {
  134.         SM_ERROR(TYPE_FATAL, Active->errno);
  135.     }
  136.  
  137.     if ((groupLink = bf_ReadPage(volRec->bufGroup, bitmapPid,
  138.                                  BITMAP_PAGE2SIZE, BF_SEM)) == NULL)    {
  139.         SM_ERROR(TYPE_FATAL, esmINTERNAL);
  140.     }
  141.  
  142.     /*
  143.      *    get a pointer to the bitmap page
  144.      */
  145.     bitmapPage = (BITMAPPAGE *) groupLink->bufFrame;
  146.  
  147.     /*
  148.      *  check to see if the lrc on the page is greater than
  149.      *  the lrc in the log record
  150.      */
  151.     if (compareLRC( &(record->actionLRC), &(bitmapPage->lrc)) <= 0)    {
  152.  
  153.         /*
  154.          *    don't need to redo
  155.          *    mark the page lrc
  156.          */
  157.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
  158.         dirtyInfo->lrc = bitmapPage->lrc;
  159.  
  160.         /*
  161.          *    release the page, clean
  162.          */
  163.         signalSemaphore( &(groupLink->pageHash->semaphore) );
  164.         bf_UnfixPage(groupLink, BF_DEFAULT, FALSE);
  165.         return;
  166.     }
  167.  
  168.     /*
  169.      *    check to see if we are to set or unset the bit
  170.      */
  171.     switch (record->action)    {
  172.  
  173.         case LOG_ACTION_MARK_FILE_PAGE:
  174.         case LOG_ACTION_MARK_SLOTTED_PAGE:
  175.  
  176.             /*
  177.              *    mark the bit
  178.              */
  179.             bm_SetBit((UFOUR *) groupLink->bufFrame, BIT_IN_PAGE(pid->page));
  180.             break;
  181.     
  182.         case LOG_ACTION_UNMARK_FILE_PAGE:
  183.         case LOG_ACTION_UNMARK_SLOTTED_PAGE:
  184.  
  185.             /*
  186.              *    mark the bit
  187.              */
  188.             bm_ClearBit((UFOUR *) groupLink->bufFrame, BIT_IN_PAGE(pid->page));
  189.             break;
  190.  
  191.         default:
  192.  
  193.             SM_ERROR(TYPE_FATAL, esmINTERNAL);
  194.             break;
  195.     }
  196.  
  197.     /*
  198.      *    set the page lsn
  199.      *    Set up the firstLSN/LRC for the page
  200.      */
  201.     bitmapPage->lrc = record->actionLRC;
  202.     DEPEND_LOG(groupLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
  203.     TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", bitmapPage->lrc.count));
  204.  
  205.     /* 
  206.      *    signal the semaphore
  207.      */
  208.     signalSemaphore( &(groupLink->pageHash->semaphore) );
  209.  
  210.     /*
  211.      *    unfix the page
  212.      */
  213.     bf_UnfixPage(groupLink, BF_DEFAULT, TRUE);
  214. }
  215.